package org.springblade.modules.ad.controller;

import org.springblade.modules.ad.entity.AdBase;
import org.springblade.modules.ad.entity.AdUser;
import org.springblade.modules.ad.service.LdapService;
import org.springblade.modules.ad.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ldap 通用 方法
 * @ClassName LdapController.java
 * @version 1.0.0
 * @author zhangyunjiao
 * @createTime 2021/8/27
 */
@RestController
@RequestMapping("/blade-test")
public class LdapController {

    @Resource
    private LdapService ldapService;


	/**
	 * ou 重命名
	 * @param adBase
	 */
	@PostMapping(value = "/renameOu")
	public Result renameOu(@RequestBody AdBase adBase){
		return ldapService.renameDn(adBase);
	}

	/**
	 * 用户，域组，ou  删除
	 * @param adBase
	 */
	@PostMapping(value = "/deleteDN")
	public Result deleteDN(@RequestBody AdBase adBase){
		return ldapService.deleteDN(adBase);
	}

	/**
	 * 查看ou 层级下的所有用户或组
	 * @param adBase
	 * @return
	 */
	@RequestMapping(value = "/getAll",method = RequestMethod.GET)
	public List<AdUser> getAll(@RequestBody AdBase adBase){
		return ldapService.getAll(adBase);
	}


}
